import { Injectable } from '@nestjs/common';
import { OnEvent } from '@nestjs/event-emitter';
import { CreateGameDto } from './dto/create-game.dto';
import logger from 'src/common/utils/log';
import { WsEmitMsg } from 'src/common/constant/constant';
import { WebsocketsServer } from 'src/common/websocket.server';

@Injectable()
export class GameListener {
  constructor(private readonly websocketServer: WebsocketsServer) {}
  @OnEvent('game.rallyUpdate')
  pushScoreUpdate(payload: CreateGameDto) {
    logger.info('handleGameRallyUpdate start');
    this.websocketServer.server.emit(WsEmitMsg.UPDATE_MATCH_SCORE, payload);
  }
}
